package com.cims.common.interceptor;

import org.apache.struts2.dispatcher.SessionMap;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class LoginInterceptor implements Interceptor{

	private static final long	serialVersionUID	= 20070504L;

	public void destroy(){
	}

	public void init(){
	}

	public String intercept(ActionInvocation invocation) throws Exception{
		System.out.println("Login interceptor fired");
		ActionContext context = invocation.getInvocationContext();
		SessionMap<?, ?> session = (SessionMap<?, ?>)context.getSession();
		if(session.get("login") == null){
			return "LOGIN";
		}

		return invocation.invoke();

	}
}